package com.itheima.framework;

import com.itheima.framework.factory.BeanFactory;
import com.itheima.framework.factory.XmlBeanFactory;
import com.itheima.framework.parse.ParseXml;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
 * @program: Implementing springmvc
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-05 10:06
 **/
public class BaseInit extends HttpServlet {
    private static ParseXml parseXml = new ParseXml();
    public static BeanFactory beanFactory;

    @Override
    public void init(ServletConfig config) throws ServletException {

        try {
            //初始化,加载所有的requestMapping的值,设置成map

            //获取所有的bean
            String springmvc = config.getInitParameter("springmvc");
            if (StringUtils.isNotBlank(springmvc)) {
                //解析xml
                parseXml.load(springmvc);
                //实例化工厂
                beanFactory = new XmlBeanFactory();
            }

            //初始化bean工厂

        } catch (Exception e) {
            e.printStackTrace();
        } finally {

        }

    }
}
